/**
 * anis.darwich
 */

package clubhouse.base;

import java.util.ListIterator;
import java.util.Vector;

public class Landmarks {
	
	private Vector<double[]> landmarks;
	public Vector<double[]> realLandmarks;
	
	public Landmarks() {
		this.landmarks = new Vector<double[]>(10,10);
		this.realLandmarks = new Vector<double[]>(10,10);
	}
	
	public int size() {
		return(this.landmarks.size());
	}
	
	public void storeLandmark(int nodeid, double X, double Y) {
		this.realLandmarks.add(new double[] {nodeid, X, Y});
		this.landmarks.add(new double[] {nodeid, X, Y});
	}
	
	public void replaceLandmark(int nodeid, double newX, double newY) {
		this.landmarks.remove(this.getLandmark(nodeid));
		this.landmarks.add(new double[] {nodeid, newX, newY});
	}
	
	public double[] getLandmark(int nodeid) {
		double[] temp = null, result = null;
        ListIterator<double[]> li = this.landmarks.listIterator();
        while(li.hasNext()){
        	temp = li.next();
        	if (temp[0] == nodeid) {
        		result = temp;
        		break;
        	}
        }
		return result;
	}
	
	public Vector<double[]> getLandmarks() {
		return this.landmarks;
	}
	
	public boolean knownLandmark(int nodeid, double X, double Y) {
		return (this.getLandmark(nodeid)!= null);
		//return this.landmarks.contains(new double[] {nodeid, X, Y});	
	}
	
	public void reinitialiseLandmarks() {
		this.landmarks = new Vector<double[]>(10,10);
		this.realLandmarks = new Vector<double[]>(10,10);
	}
}
